<?php include('header.php');?>
<?php
//ค้นหาสินค้า
if($_GET['action']=='del'){
	$delOK = mysql_query("DELETE FROM group_detail WHERE group_detail_id = '".$_GET["id"]."'");
	mysql_query("DELETE FROM group_detail_room WHERE group_detail_id = '".$_GET["id"]."'");
	if($delOK){
		echo "<script>history.go(-1)</script>";
	}
}

if($_POST["group_search"] != "") {
	
	$group_search = $_POST["group_search"];

	$Query = "SELECT * FROM group_detail WHERE 1 ";

	if($group_search != "") {
		$Query .= "AND group_detail_name LIKE '%".$group_search."%' ";
	}
	
	$Query .= "ORDER BY group_detail_name";

} else {
	$Query = "SELECT * FROM group_detail ORDER BY group_detail_name";
}
$objQuery = mysql_query($Query) or die ("Error Query [".$Query."]");
?>
<body>
<div class="box">
  <div class="left"></div>
  <div class="right"></div>
    <div class="heading"><h1>จัดการบริษัททัวร์</h1>
    <div class="buttons"><a onclick="window.location='group_add.php'" class="button"><span>เพิ่มบริษัททัวร์</span></a></div>
    </div>
  <div class="content">
  <table class="list">
        <thead>
          <tr>
            <td width="1" class="center"><span class="center">ลำดับ</span></td>
            <td class="center">ชื่อบริษัททัวร์</td>
            <td class="center">จัดการราคาห้องพัก</td>
            <td class="center">จัดการ</td>
          </tr>
        </thead>
        <tbody>
		<form action="<?php $_SERVER["PHP_SELF"];?>" name="formsearch" method="post" id="formsearch">
          <tr class="filter">
            <td align="center"></td>
            <td align="center"><input name="group_search" type="text" id="group_search" value="<?php echo $group_search;?>" onkeydown="if(event.keyCode==13){formsearch.submit();}" style="text-align: center;" /></td>
            <td align="center"></td>
            <td align="center"><a onclick="formsearch.submit();" class="button"><span>ค้นหา</span></a></td>
          </tr>
		</form>
<?php
	$num = 0;
	while($row = mysql_fetch_array($objQuery))
		{
		$num++;
?>
          <tr>
          	<td class="center"><?php echo $num;?></td>
            <td class="center"><?php echo $row["group_detail_name"];?></td>
            <td class="center">[ <a href="group_price_edit.php?id=<?php echo $row["group_detail_id"];?>">แก้ไขราคา</a> ]</td>
            <td class="center">[ <a href="group_edit.php?id=<?php echo $row["group_detail_id"];?>">แก้ไข</a> ] [ <a href="JavaScript:if(confirm('คุณต้องการยืนยันการลบข้อมูล ใช่หรือไม่?')==true){window.location='?action=del&id=<?php echo $row["group_detail_id"];?>'}">ลบ</a> ]</td>
          </tr>
<?php
		} 
?>
        </tbody>
      </table>
  </div>
</div>

</body>
<?php include('footer.php');?>

